/**
 * 省事区三级联动
 */
function _init_area(province_id,city_id,area_id,select_province,select_city,select_area,base_url){
	$('#'+province_id).change(function(){
		city_option(province_id,city_id,area_id,select_city,select_area,base_url);
	});
	$('#'+city_id).change(function(){
		area_option(city_id,area_id,select_area,base_url);
	});
	$.ajax( {
        url:base_url+'api/common/province',
        data:{},
        type:'post',
        cache:false,
        dataType:'json',    
        success:function(data) {
        	var province = document.getElementById(province_id);
        	province.options.length = 1;
        	for(var i=0; i<data.province.length; i++)
			{
        		var len = province.length;
        		province.options[len] = new Option(data.province[i].province, data.province[i].provinceid);
				if (province.options[len].value == select_province)
				{
					province.options[len].selected = true;
				}
			}
        	city_option(province_id,city_id,area_id,select_city,select_area,base_url);
        },
        error : function() {       
            alert("error");
        }
	});
}
function city_option(province_id,city_id,area_id,select_city,select_area,base_url){
	$.ajax( {
        url:base_url+'api/common/city',
        data:{province_id:$('#'+province_id).val()},
        type:'post',
        cache:false,
        dataType:'json',    
        success:function(data) {
        	var city = document.getElementById(city_id);
        	city.options.length = 1;
        	for(var i=0; i<data.city.length; i++)
			{
        		var len = city.length;
        		city.options[len] = new Option(data.city[i].city, data.city[i].cityid);
				if (city.options[len].value == select_city)
				{
					city.options[len].selected = true;
				}
			}
        	area_option(city_id,area_id,select_area,base_url);
        },
        error : function() {       
            alert("error");
        }
	});
}
function area_option(city_id,area_id,select_area,base_url){
	$.ajax( {
        url:base_url+'api/common/area',
        data:{city_id:$('#'+city_id).val()},
        type:'post',
        cache:false,
        dataType:'json',    
        success:function(data) {
        	var area = document.getElementById(area_id);
        	area.options.length = 1;
        	for(var i=0; i<data.area.length; i++)
			{
        		var len = area.length;
        		area.options[len] = new Option(data.area[i].area, data.area[i].areaid);
				if (area.options[len].value == select_area)
				{
					area.options[len].selected = true;
				}
			}
        	
        },
        error : function() {       
            alert("error");
        }
	});
}